import { post } from '@/utils/request'
import moment from 'moment';

/**
 * 加载泵车数据
 */
export function loadSystemLogData (data) {
	return post('/forman/getSystemMsg', Object.assign({
		pageNo: 0,
		pageSize: 20
	}, data))
}

export function getBeijingTime (data) {
	const now = new Date()
	const offset = now.getTimezoneOffset() // 分钟偏移
	const beijingTime = new Date(now.getTime() + (3600000 * (8 - (-offset / 60))))
	console.log(beijingTime, offset)
	const year = beijingTime.getFullYear()
	const month = String(beijingTime.getMonth() + 1).padStart(2, '0')
	const day = String(beijingTime.getDate()).padStart(2, '0')
	const hours = String(beijingTime.getHours()).padStart(2, '0')
	const minutes = String(beijingTime.getMinutes()).padStart(2, '0')

	return `${year}-${month}-${day} ${hours}:${minutes}`

}

export function get (data) {
	const now = new Date()
	const offset = now.getTimezoneOffset() // 分钟偏移
	const beijingTime = new Date(now.getTime() + (3600000 * (8 - (-offset / 60))))
	console.log(beijingTime, offset)
	const year = beijingTime.getFullYear()
	const month = String(beijingTime.getMonth() + 1).padStart(2, '0')
	const day = String(beijingTime.getDate()).padStart(2, '0')
	const hours = String(beijingTime.getHours()).padStart(2, '0')
	const minutes = String(beijingTime.getMinutes()).padStart(2, '0')

	return `${year}-${month}-${day} ${hours}:${minutes}`

}
